<?php

$con = mysql_connect('localhost','root','root') or die('请检查数据库连接'.mysql_error());
mysql_query("SET NAMES gb2312");
$db = mysql_select_db("get_content",$con);

if(!$db){
	die("数据库不存在".mysql_error());
}else {
	$sql = "SELECT * FROM `spiders` LIMIT 0,30;";
	$result = mysql_query($sql,$con);
	$row = mysql_fetch_array($result);
	
	if(isset($_POST['flag']) && $_POST['flag'] == 1){
		//更新定义规则
		$sql1 = "UPDATE `spiders` SET `listpreg` = '".$_POST['listpreg']."',contentpreg = '".$_POST['contentpreg']."',enterurl = '".$_POST['enterurl']."WHERE `spiders`.`id` = 4 LIMIT 1";
		$result1 = mysql_query($sql1,$con);
		mysql_free_result($result1);
		mysql_close($db);
		header("location:manage.php");
	}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>采集器管理界面</title>
</head>
<body>
	<h1>采集器管理界面</h1>
	<div>
	<form action="manage.php" method="post">
		<input type="hidden" name="flag" value="1">
		<span>采集描述</span><input type="text" size="30" value="<?php echo $row['title']; ?>"  /><br />
		<span>所属栏目</span><select><option value="1"><?php echo $row['category']; ?></option></select><br />
		<span>列表页面地址</span><input type="text" size="60" value="<?php echo $row['enterurl']; ?>" /><br />
		<span>列表页匹配描述</span><textarea cols="80" rows="4"><?php echo $row['listpreg']; ?></textarea><br />
		<span>内容页匹配描述</span><textarea cols="80" rows="4"><?php echo $row['contentpreg']; ?></textarea><br />
		<input type="submit"value="规则提交" name="submit" /><input type="button" value="开始采集" onclick="loadS1()" />
	</form>
	</div>
	<script>
		function loadS1(){
			window.open('spiders.php?cid=1');
		}
	</script>
</body>
</html>